export default {
	namespaced: true,//命名空间必须写
	state: {
		token: null,
		// 用户账号
		username: null,
		// 用户昵称
		nickName: null,
		userId: null,
		// 手机号
		mobile: null,
		// 头像
		avatar: null,
		deptId: null,
		email: null,
		roles: [],
		permissions: [],

		// 下面是微信相关
		openid: null,
		sessionKey: null,
		unionid: null,
	},
	mutations: {
		SET_TOKEN(state, token) {
			state.token = token
		},
		SET_SESSION_RESULT(state, {openid, sessionKey, unionid}) {
			state.openid = openid
			state.sessionKey = sessionKey
			state.unionid = unionid
		}
	},
	// 异步方法
	actions:{
		setToken({ commit }, token) {
			commit('SET_TOKEN', token)
		},
		setSessionResult({ commit }, { openid, sessionKey, unionid }) {
			commit('SET_SESSION_RESULT', {openid, sessionKey, unionid})
		}
	},
	getters: {
		getToken: (state) => {
			return state.token
		}
	}
}